
<?php
$flashMessages = Yii::app()->user->getFlashes();
if ($flashMessages) {
    foreach($flashMessages as $key => $message) {
        echo '<div class="alert alert-' . $key . ' fade in"><button type="button" class="close" data-dismiss="alert">×</button>' . $message . "</div>\n";
    }
}
?>
<section class="add-record">
    <?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
        'id'=>'tracking_add_form',
        'type'=>'horizontal',
    ));?>

    <fieldset>
        <legend>
            <?php echo Yii::t('app', 'Edit record') ?>
            <a class="btn-back pull-right" href="<?php echo $this->createUrl('tracking/index')?>">← <?php echo Yii::t('app', 'Back to List') ?></a>
        </legend>
        <?php

        echo $form->dropDownListRow($model, 'id_client', $listClient,
            array(
                'empty' => Yii::t('app', 'Please select client'),
                'disabled' => true
            )
        )
        ?>
        <?php echo $form->dropDownListRow($model, 'id_tpdetail', $listTrensporter, array('empty'=>Yii::t('app', 'Please select transported'))) ?>

        <div class="control-group ">
            <label for="Task_delivery_date" class="control-label required">
                <?php echo Yii::t('app', 'Shipping Date') ?> <span class="required">*</span>
            </label>
            <div class="controls">
                <?php
                $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                    'model' => $model,
                    'attribute' => 'ship_date',
                    'options' => array(
                        'dateFormat' => 'yy-mm-dd',
                    ),
                    'htmlOptions' => array(
                        'maxlength' => 8,
                        'readonly' => 'readonly',
                    ),
                ));
                ?>
            </div>
        </div>

        <div class="control-group ">
            <div class="controls">
                <select multiple="multiple" size="10" disabled="disabled">
                    <?php if($model->id_client): ?>
                        <?php $listTaskByClient = Task::_getTaskByClient($model->id_client); ?>
                        <?php if($listTaskByClient): ?>
                            <?php foreach($listTaskByClient as $task): ?>
                                <option value="<?php echo $task->id_task; ?>" <?php if(in_array($task->id_by_matter,$listTrackingTask)): echo 'selected'; endif; ?>>
                                    <?php echo $task->id_by_matter; ?>
                                </option>
                            <?php endforeach; ?>
                        <?php endif ?>
                    <?php endif ?>
                </select>
                <?php /*
                <select multiple="multiple" size="10" name="id_matter_task[]" id="id_matter_task">
                    <?php if($model->id_client): ?>
                        <?php $listTaskByClient = Task::_getTaskByClient($model->id_client); ?>
                        <?php if($listTaskByClient): ?>
                            <?php foreach($listTaskByClient as $task): ?>
                                <option value="<?php echo $task->id_task; ?>" <?php if(in_array($task->id_by_matter,$listTrackingTask)): echo 'selected'; endif; ?>>
                                    <?php echo $task->id_by_matter; ?>
                                </option>
                            <?php endforeach; ?>
                        <?php endif ?>
                    <?php endif ?>
                </select>
                 */ ?>
            </div>
        </div>

        <div class="control-group">
            <label class="control-label">
                <?php echo Yii::t('app', 'Signature') ?>
            </label>
            <div class="controls signature-pad">
                <?php echo CHtml::image(Yii::app()->getBaseUrl().'/signature/'.$model->id_tracking.'.png'); ?>
            </div>
        </div>

    </fieldset>
    <div class="form-actions">
        <?php
        $this->widget('bootstrap.widgets.TbButton', array(
            'buttonType' => 'submit',
            'type' => 'primary',
            'label' => Yii::t('app', 'Submit'),
            'icon' => 'plus-sign white'
        ));
        ?>
    </div>
    <?php $this->endWidget();?>
</section>
